
# 在代码开始部分添加
import os
from fastapi import FastAPI
import uvicorn
from fastapi.middleware.cors import CORSMiddleware
import transferUtil
import kdbUtil
import searchUtil
import roleAgentUtil
import deviceBankUtil
import soundBankUtil
import userUtil

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins = ["*"],
    allow_methods = ["*"],
    allow_headers= ["*"]
)
app.include_router(transferUtil.router)
app.include_router(kdbUtil.router)
app.include_router(searchUtil.router)
app.include_router(roleAgentUtil.router)
app.include_router(soundBankUtil.router)
app.include_router(deviceBankUtil.router)
app.include_router(userUtil.router)

if __name__ == '__main__':
    # 使用 uvloop 作为事件循环策略

    # 配置并运行 Uvicorn
    uvicorn.run(
        app='server:app',  # 注意这里应该是 'server:app' 而不是 app 对象本身
        host="0.0.0.0",
        port=8000,
        workers=16,  # 设置工作进程数量
    )